package impl.persons;

import framework.Business;
import framework.PersonAdapter;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

/**
 * Implements "Tit For Tat" personal strategy.
 *
 * @author Denis DIR Rozhnev
 */
public class WaitForGood extends PersonAdapter {
    static Logger LOG = Logger.getLogger(WaitForGood.class);
    private Map<Object, Boolean> flag = new HashMap<Object, Boolean>();

    public String getShortName() {
        return "WFG";
    }

    @Override
    public int deal(Object id) {
        if (flag.containsKey(id)) {
//            LOG.debug("Person: " + id + " History: " + Business.DEFECT);
            return Business.COOPERATE;
        }
//        LOG.debug("Person: " + id + " COOPERATING");
        return Business.DEFECT;
    }

    @Override
    public void dealed(Object id, int deal) {
		if(deal == Business.COOPERATE) {
			flag.put(id, Boolean.TRUE);
		}
    }
}